﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using report_view;
using ReportModel;
/*======================================
 *author lixiao
 *mail lixiao.god@qq.com
 ======================================*/
    namespace ReportView
{
    
    public partial class MainForm : Form
    {
        public Dictionary<int, string> daysInWeek1;
        public Dictionary<int, string> daysInWeek2;
        public MainForm()
        {
            InitializeComponent();
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("开始："+Generator.GetDateByIndex(int.Parse(comboBox1.SelectedValue.ToString())).Date.ToShortDateString());
            //MessageBox.Show("结束：" + Generator.GetDateByIndex(int.Parse(comboBox2.SelectedValue.ToString())).Date.ToShortDateString());

            try
            {
                generate();
            }
            catch(Exception exception)
            {
                MessageBox.Show(exception.Message);
                
            }
            


        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {
                
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            int gLeft = this.Width / 2 - groupControl1.Width / 2;

            int gTop = this.Height / 2 - groupControl1.Height / 2;

            groupControl1.Location = new Point(gLeft, gTop);
            initSetings();
            
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_MouseClick(object sender, MouseEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "word 文件(*.doc;*.docx)|*.doc;*.docx";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.reportFilePath.Text = dialog.FileName;
            }
             
        }
        private void reportFilePath_MouseClick(object sender, MouseEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "word 文件(*.doc;*.docx)|*.doc;*.docx";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.reportFilePath.Text = dialog.FileName;
            }
             
        }

        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            saveSetings();
        }

        private void changeTplChkbx_CheckedChanged(object sender, EventArgs e)
        {
            if (changeTplChkbx.Checked)
            {
                reportFilePath.MouseClick += new MouseEventHandler(this.reportFilePath_MouseClick);
            } else
            {
                reportFilePath.MouseClick-= new MouseEventHandler(this.reportFilePath_MouseClick);
            }
        }

        private void SelectNextWeekDateChkBx_CheckedChanged(object sender, EventArgs e)
        {
            if (SelectNextWeekDateChkBx.Checked)
            {
                nextWeekStartDatePk.Enabled = true;
                nextWeekEndDatePk.Enabled = true;
            }
            else
            {
                nextWeekStartDatePk.Enabled = false;
                nextWeekEndDatePk.Enabled = false;

            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            AboutForm aboutForm = new AboutForm();
            aboutForm.Show();
        }
    }
}
